package com.yc.bbs.controller;

import com.yc.bbs.vo.Person;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    @RequestMapping("hello")
    public String hello(String name){
        return "你好 " + name;
    }

    // value 注解可以使用 SpringEL 表达式注入一个环境参数
    @Value("${demo.name}")
    String demoName;

    @Value("${demo.age}")
    int demoAge;

    @Value("${demo.familys.father}")
    String father;

    @RequestMapping("test")
    String test(){
        return String.format("%s : %s : %s", demoName,demoAge,father);
    }

    @Autowired
    Person person;

    @RequestMapping("person")
    Person getPerson(){
        return person;
    }
}
